function msValue() {
  return {
    restrict: 'A',
    link(scope, iElement, iAttrs) {
      const value = iAttrs.msValue;
      const msModel = scope.$ctrl.msModel;
      msModel.push(value);

      iElement.on('$destroy', () => {
        const index = msModel.indexOf(value);
        msModel.splice(index, 1);
      });
    },
  };
}

export default msValue;
